/************************************************************************/
/*Copyright (c) James Zhao 2007,2008
/*This file is part of AdminOverlay.
/*AdminOverlay is free software: you can redistribute it and/or modify
/*it under the terms of the GNU General Public License as published by
/*the Free Software Foundation, either version 3 of the License, or
/*(at your option) any later version.
/*
/*AdminOverlay is distributed in the hope that it will be useful,
/*but WITHOUT ANY WARRANTY; without even the implied warranty of
/*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
/*GNU General Public License for more details.
/*
/*You should have received a copy of the GNU General Public License
/*along with Foobar.  If not, see <http://www.gnu.org/licenses/>.                                                                     */
/*************************************************************************/
#pragma once
#include "listpanel.h"
#include "GraphicsKit.h"

class EXPORT_UIKIT  TabPanel :
	public ListPanel
{
	Q_OBJECT
public:
	using ListPanel::NeedUpdate;
	TabPanel(int x, int y, int width, int height, int titleMargin = 60,
		int tabWidth = 150, int tabGap = 10, int tabHeight = 30);
	~TabPanel(void);
	void layout(QPoint offset);
	void draw(LPDIRECT3DDEVICE9 device);
	void onSelectItem(int index);

	void onDeviceReset();
	void addItem(TabItem *item);
public slots:
	void onMouseDown(QPoint point, bool isPrimaryTarget);
public:
	int TitleMargin() const { return titleMargin; }
	void TitleMargin(int val) { titleMargin = val; }
	void NeedUpdate(bool val);
private:
	int tabWidth;
	int tabHeight;
	int tabGap;
private:
	TextVisual *title;
	LineBuffer *lineBuffer;
	//					 -----------------  <-centerLine
	//		vLeftLine->	 |				 | <-vRightLine
	//-------------------				 -------------------
	//		^leftLine							^rightLine
	//
	LineVisual *leftLine;
	LineVisual *rightLine;
	QVector<LineVisual*> tabLines;
	int titleMargin;
	QPointer<UIPanel> activeContentPanel;
private:
	void layoutLines();
};